home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CKeyControlsDialog.cp < prev    next >
Text File  |  1994-05-02  |  6KB  |  174 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CKeyEditControlsDialog.cp
  3. //|
  4. //| This implements the dialog used to edit key controls
  5. //|_________________________________________________________
  6.  
  7. #include "CKeyControlsArrayPane.h"
  8. #include "CKeyControlsDialog.h"
  9. #include "CHyperCuberPrefs.h"
  10.  
  11. #include "HyperCuber Balloons.h"
  12. #include "HyperCuber Commands.h"
  13.  
  14. #include <CButton.h>
  15. #include <CPaneBorder.h>
  16. #include <CDecorator.h>
  17. #include <CEditText.h>
  18.  
  19. #include <string.h>
  20.  
  21. //============================ Globals ===============================\\
  22.  
  23. extern CDecorator         *gDecorator;
  24. extern CHyperCuberPrefs *gPrefs;
  25.  
  26.  
  27.  
  28. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. //| CKeyControlsDialog::IKeyControlsDialog
  30. //|
  31. //| Purpose: Initialize the controls dialog.
  32. //|
  33. //| Parameters: WindowID:   ID of WIND resource to use
  34. //|             enclosure:  the Desktop
  35. //|             supervisor: the supervisor of this DialogDirector
  36. //|             array:      the array of key controls
  37. //|______________________________________________________________________________
  38.  
  39. void CKeyControlsDialog::IKeyControlsDialog(short WindowID, CDesktop *enclosure,
  40.                                             CDirector *supervisor, CArray *array,
  41.                                                 CKeyControlsArrayPane *array_pane)
  42. {
  43.  
  44.     
  45. #define OKAY_BUTTON_ID        130
  46. #define CANCEL_BUTTON_ID    131
  47. #define DEFAULTS_BUTTON_ID    132
  48. #define ADD_BUTTON_ID        133
  49. #define REMOVE_BUTTON_ID    134
  50. #define EDIT_BUTTON_ID        135
  51.  
  52.  
  53.     CDialog::IDialog(WindowID, enclosure, supervisor);    //  Initialize window from WIND resource
  54.  
  55.     helpResID = WINDOW_HELP_RES;                    //  Link in the Balloon Help
  56.  
  57.     CButton        *button;
  58.     button = new(CButton);                            //  Set up the okay button
  59.     button->IButton(OKAY_BUTTON_ID, this, this);
  60.     button->Offset(350, 35, TRUE);
  61.     button->SetClickCmd (cmdOK);
  62.     button->helpResIndex = kKeyOkay;
  63.     SetDefaultButton(button);
  64.     
  65.     button = new (CButton);                            //  Set up the cancel button
  66.     button->IButton(CANCEL_BUTTON_ID, this, this);
  67.     button->Offset(350, 70, TRUE);
  68.     button->SetClickCmd (cmdCancel);
  69.     button->helpResIndex = kKeyCancel;
  70.     
  71.     button = new (CButton);                            //  Set up the Defaults button
  72.     button->IButton(DEFAULTS_BUTTON_ID, this, this);
  73.     button->Offset(350, 105, TRUE);
  74.     button->SetClickCmd (cmdDefaults);
  75.     button->helpResIndex = kKeyDefaults;
  76.     
  77.     button = new (CButton);                            //  Set up the Add button
  78.     button->IButton(ADD_BUTTON_ID, this, this);
  79.     button->Offset(350, 140, TRUE);
  80.     button->SetClickCmd (cmdAdd);
  81.     button->helpResIndex = kKeyAdd;
  82.     
  83.     button = new (CButton);                            //  Set up the Remove button
  84.     button->IButton(REMOVE_BUTTON_ID, this, this);
  85.     button->Offset(350, 175, TRUE);
  86.     button->SetClickCmd (cmdRemove);
  87.     button->helpResIndex = kKeyRemove;
  88.     
  89.     button = new (CButton);                            //  Set up the Edit button
  90.     button->IButton(EDIT_BUTTON_ID, this, this);
  91.     button->Offset(350, 210, TRUE);
  92.     button->SetClickCmd (cmdEdit);
  93.     button->helpResIndex = kKeyEdit;
  94.     
  95.     CScrollPane *scroll_pane;
  96.     scroll_pane = new(CScrollPane);                    //  Set up the scrolling pane
  97.     scroll_pane->IScrollPane(this, this, 300, 254,
  98.                             20, 20,
  99.                             sizFIXEDLEFT, sizFIXEDTOP,
  100.                             FALSE, TRUE, FALSE);
  101.     
  102.     CPaneBorder *border;
  103.     border = new(CPaneBorder);                        //  Add a box around the scroll pane
  104.     border->IPaneBorder(kBorderFrame);
  105.     Rect margin = {1, 1, -1, -1};
  106.     border->SetMargin(&margin);
  107.     scroll_pane->SetBorder(border);
  108.  
  109.     array_pane->IKeyControlsArrayPane(scroll_pane, scroll_pane,
  110.                         10, 10, 0, 0,
  111.                         sizFIXEDLEFT, sizFIXEDTOP);    //  Set up the array pane
  112.     array_pane->FitToEnclosure(TRUE, TRUE);
  113.     array_pane->SetArray(array, TRUE);
  114.     array_pane->SetDblClickCmd(cmdEdit);
  115.     
  116.     scroll_pane->InstallPanorama(array_pane);
  117.  
  118.     CEditText *text;
  119.     text = new(CEditText);                                    //  Set up the Function text
  120.     text->IEditText(this, this, 100, 16,
  121.                     23, 3, sizFIXEDLEFT, sizFIXEDTOP, -1);
  122.     text->SetTextString("\pFunction");
  123.     text->SetFontNumber(systemFont);
  124.     text->SetFontSize(12);
  125.     text->SetWantsClicks(FALSE);
  126.     text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  127.     
  128.     text = new(CEditText);                                    //  Set up the Key text
  129.     text->IEditText(this, this, 100, 16,
  130.                     239, 3, sizFIXEDLEFT, sizFIXEDTOP, -1);
  131.     text->SetTextString("\pKey");
  132.     text->SetFontNumber(systemFont);
  133.     text->SetFontSize(12);
  134.     text->SetWantsClicks(FALSE);
  135.     text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  136.     
  137.  
  138.     gDecorator->CenterWindow (this);                //  Center the window on the screen
  139.  
  140. }    //=== CKeyControlsDialog::IKeyControlsDialog() ===\\
  141.  
  142.  
  143.  
  144. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145. //| CKeyControlsDialog::MatchDialogToPrefs
  146. //|
  147. //| Purpose: Sets the values of the keys in the dialog to match the prefs
  148. //|______________________________________________________________________________
  149.  
  150. void CKeyControlsDialog::MatchDialogToPrefs(void)
  151. {
  152.  
  153.     PrefsStruct prefs = gPrefs->prefs;        // Get current prefs
  154.  
  155. #if 0
  156.     increase_theta_keypane->SetKey(prefs.increase_theta_key);
  157.     decrease_theta_keypane->SetKey(prefs.decrease_theta_key);
  158.     increase_phi_keypane->SetKey(prefs.increase_phi_key);
  159.     decrease_phi_keypane->SetKey(prefs.decrease_phi_key);
  160.     increase_rho_keypane->SetKey(prefs.increase_rho_key);
  161.     decrease_rho_keypane->SetKey(prefs.decrease_rho_key);
  162.     increase_alpha_keypane->SetKey(prefs.increase_alpha_key);
  163.     decrease_alpha_keypane->SetKey(prefs.decrease_alpha_key);
  164.     increase_beta_keypane->SetKey(prefs.increase_beta_key);
  165.     decrease_beta_keypane->SetKey(prefs.decrease_beta_key);
  166.     increase_gamma_keypane->SetKey(prefs.increase_gamma_key);
  167.     decrease_gamma_keypane->SetKey(prefs.decrease_gamma_key);
  168.     increase_delta_keypane->SetKey(prefs.increase_delta_key);
  169.     decrease_delta_keypane->SetKey(prefs.decrease_delta_key);
  170.  
  171.     times_ten_mod_menu->GetMenu()->SelectItem(prefs.times_ten_modifier, pmForceOn);
  172. #endif
  173.     
  174. }    //==== CKeyControlsDialog::MatchDialogToPrefs() ====\\